package com.adminlab.test
{
	import com.adminlab.managers.PersistenceManager;
	import com.adminlab.vos.Report;
	
	import flashx.textLayout.debug.assert;
	
	import flexunit.framework.Assert;
	
	import mx.core.mx_internal;
	
	import org.flexunit.asserts.assertNotNull;
	import org.flexunit.asserts.assertTrue;
	
	public class TestPersistenceManager
	{		
		private var reportToSave:Report;
		private var reportToSave2:Report;
		
		private var persistenceManager:PersistenceManager;
		
		[Before]
		public function setUp():void
		{
			reportToSave = new Report();
			reportToSave.name = "Albert Einstein";
			reportToSave.docthor = "Pastuer";
			reportToSave.created = new Date();
			reportToSave.delived = new Date();
			
			reportToSave2 = new Report();
			reportToSave2.name = "Carlos Gardel";
			reportToSave2.docthor = "Pasteur";
			reportToSave2.created = new Date();
			reportToSave2.delived = new Date();
			
			persistenceManager = new PersistenceManager();
		}
		
		[After]
		public function tearDown():void
		{
		}
		
		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}
		
		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}
		
		[Test]
		public function testSaveReport():void
		{
			Assert.assertNotNull( reportToSave, "No deberia ser null" );
			//Assert.fail("Test method Not yet implemented");
			
			persistenceManager.clearDataDirectory();
			
			assertTrue( persistenceManager.saveReport( reportToSave ) );	
			assertTrue( persistenceManager.saveReport( reportToSave2 ) );
			
			assertNotNull( persistenceManager.getReportList() );
		}
	}
}